/// <reference path="../Scripts/qunit.d.ts" />
/// <reference path="../../BattleThis/Scripts/Game/GameEntitys.ts" />
QUnit.module("UnitParserTest")
{

    test("Test empty value", () => {

        //Arrange
        var target = new BattleThis.UnitParser();
        var expect = new IUnit[];

        //Act
        var result = target.parse("test");

        //Assert
        equal(result.length, expect.length, "Check");

    });

    test("Test parse valide value", () => {

        //Arrange
        var target = new BattleThis.UnitParser();
        var expect = 1

        //Act
        var result = target.parse("<div class='InfoUnit'><input name='Id' value='1'/></div>");

        //Assert
        equal(result.length, expect, "Check");

    });

    test("Test parse invalid value", () => {

        //Arrange
        var target = new BattleThis.UnitParser();

        //Act
        try
        {
            
            target.parse("<div class='InfoUnit'><input name='Id' value='-1'/></div>");
        }
        catch (ex)
        {
             //Assert
            ok(ex instanceof BattleThis.ArgException, "ArgumentEx expected");
        }

    });

    test("Test parse result", () => {

        //Arrange
        var expectedId = 1;
        var expectedArmor = 50;
        var expectedExperience = 3;
        var target = new BattleThis.UnitParser();

        //Act
        var result = target.parse("<div class='InfoUnit'>" +
                                        "<input name = 'Id' value = '" + expectedId + "' / >" +
                                        "<div class='unitPower'>" +
                                            "<div class='damage' style ='height: " + expectedArmor +"' >" +
                                                "<span>"+ expectedArmor +"</span>" +
                                             "</div>" +
                                        "</div>" +
                                        "<div class='expierence'>"+
                                            "<img  title='" + expectedExperience + "' />" +
                                        "</div>" +
                                    "</ div> ")[0];
       
        //Assert
        equal(result.id, expectedId, "expected id is invalid.");
        equal(result.armor, expectedArmor, "expected armor is invalid.");
        equal(result.experience, expectedExperience, "expected experience is invalid.");
       
    });

}